package com.itheima.dao;

import com.itheima.domain.Permission;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IPermissionDao {

    /**
     * 查询所有权限信息
     *
     * @return
     */
    @Select("select * from permission")
    List<Permission> findAllPermission();


    /**
     * 查询角色对应的权限信息
     *
     * @return
     */
    @Select("select * from PERMISSION where id in(select PERMISSIONID from ROLE_PERMISSION where ROLEID = #{roleId})")
    public List<Permission> findPermissionByRole();

    /**
     * 添加新权限信息
     *
     * @param permission
     */
    @Insert("insert into permission(id,permissionName,url) values(sys_guid(),#{permissionName},#{url})")
    void insertPermission(Permission permission);
}
